<!--
 * @Description: 工程投标
 * @Author: wangwangwang
 * @Date: 2020-08-17 15:52:58
 * @LastEditors: wangwangwang
 * @LastEditTime: 2021-08-12 17:22:52
-->
<template>
  <div class="pages_content table">
    <el-container>
      <el-header>
        <breaDcrumb />
      </el-header>
      <el-main>
        <div class="header_right" @click="showCardNav = !showCardNav">
          <div class="title">搜索</div>
          <div>
            <transition name="from"></transition>
            <span v-show="!showCardNav">
              <i style="margin-right: 5px" class="el-icon-arrow-down"></i>
            </span>
            <transition name="to"></transition>
            <span v-show="showCardNav">
              <i style="margin-right: 5px" class="el-icon-arrow-up"></i>
            </span>
          </div>
        </div>
        <div v-show="showCardNav" class="hr"></div>
        <el-collapse-transition>
          <div v-show="showCardNav">
            <div class="search">
              <span>
                <span style="margin-right: 12px">工程名称</span>
                <el-input v-model="tableParam.name" style="width: 200px" clearable placeholder="请输入" @keyup.enter.native="gettableData()" />
              </span>
              <!-- <span style="margin-left: 24px">
                <span style="margin-right: 12px">客户名称</span>
                <el-input v-model="tableParam.roadwork" style="width: 20%; max-width: 200px" clearable placeholder="请输入" @keyup.enter.native="gettableData()" />
              </span> -->
              <el-button icon="el-icon-search" size="medium" class="bottom_all but1" @click="(tableParam.page = 1), gettableData()">查 询</el-button>
              <el-button size="medium" class="bottom_all_two" style="margin-left: 12px" @click="init()">重 置</el-button>
              <el-button size="medium" class="bottom_all_two" style="margin-left: 12px" @click="tableParamType = true">高级搜索</el-button>
            </div>
          </div>
        </el-collapse-transition>
        <div class="hr"></div>
        <div class="card" style="padding-top: 10px">
          <div v-loading="tableLoading" class="card_info" :style="style">
            <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="tableData" tooltip-effect="dark">
              <el-table-column prop="code" align="center" label="工程编号"></el-table-column>
              <el-table-column prop="name" align="center" label="工程名称">
                <!-- <template slot-scope="scope">
                  <el-link class="table_link" :underline="false" @click="handleDetails(scope.row)">{{scope.row.name}}</el-link>
                </template> -->
              </el-table-column>
              <!-- <el-table-column prop="roadwork" align="center" label="施工单位"></el-table-column>
              <el-table-column prop="roadworklInkman" align="center" label="联系人"></el-table-column>
              <el-table-column prop="roadworkPhone" align="center" label="联系电话"></el-table-column> -->
              <el-table-column prop="createTime" align="center" label="登记时间"></el-table-column>
              <el-table-column prop="principal" align="center" label="负责人"></el-table-column>
              <el-table-column prop align="center" label="投标状态" width="284">
                <template slot-scope="scope">
                  <el-radio-group v-model="scope.row.bidStatus" @change="change1(scope.row, scope.$index)">
                    <el-radio :label="1">投标中</el-radio>
                    <el-radio :label="2">已中标</el-radio>
                    <el-radio :label="3">未中标</el-radio>
                  </el-radio-group>
                </template>
              </el-table-column>
              <el-table-column align="center" label="投标信息" width="120">
                <template slot-scope="scope">
                  <el-link v-if="ButtonList.findIndex(res=>(res.buttonValue=='TIANXIE'))!==-1" class="table_link" :underline="false" @click="editorTender(scope.row),handleIndex=''">填写</el-link>
                </template>
              </el-table-column>
              <el-table-column align="center" label="投标配合比" width="120">
                <template slot-scope="scope">
                  <el-link v-if="ButtonList.findIndex(res=>(res.buttonValue=='TIANXIE'))!==-1" class="table_link" :underline="false" @click="editorMix(scope.row)">{{scope.row.fillIn===1?'调整':'填写'}}</el-link>
                </template>
              </el-table-column>
              <el-table-column fixed="right" align="center" width="120" label="投标附件">
                <template slot-scope="scope">
                  <el-button class="bottom_one" size="mini" @click="look5Fun(scope.row)">
                    编辑
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </el-main>
      <div class="card_bottom">
        <div class="card_bottom_left">
          <div class="top_page_totle">总共{{ total }}条</div>
          <el-pagination :current-page.sync="tableParam.page" :page-size="tableParam.pageSize" :page-sizes="[10, 20, 30, 40,50,100,200,500,1000]" layout="prev,pager,sizes,next,jumper" :total="total" @size-change="sizeChange" @current-change="gettableData()"></el-pagination>
        </div>
        <div>
          <el-button size="mini" icon="el-icon-refresh-right" class="bottom_all_two" @click="gettableData">刷新</el-button>
        </div>
      </div>
    </el-container>
    <!-- 投标产品配合比 -->
    <el-dialog v-dialogDrag :visible="dialogList.indexOf(activedialog) == 0" width="680px" :close-on-click-modal="false" :before-close="closedialog">
      <span slot="title" class="dialog-title">投标产品配合比</span>
      <div class="dialoginfo" style="padding-top: 0">
        <div style="padding-bottom:20px;">
          <el-radio-group v-model="radioType" @change="radioTypeFun()">
            <el-radio :label="1">
              <span>取用公司标准配合比</span>
            </el-radio>
            <el-radio :label="2">
              <span>配置特定配合比</span>
            </el-radio>
          </el-radio-group>
        </div>
        <div v-if="radioType==2" style="padding-bottom:10px">
          <el-button size="mini" class="bottom_all" style="margin-left: 0" @click="addItem()">
            <i class="icon iconfont iconicon_button_add" style="font-size: 12px"></i>
            添加
          </el-button>
        </div>
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="table" tooltip-effect="dark" show-overflow-tooltip>
          <el-table-column align="center" label="标号" prop="markNumber">
            <template slot-scope="scope">
              <el-select v-model="scope.row.markNumberId" :disabled="radioType==1" placeholder="请选择" style="width:100%" @change="change(scope.row,scope.$index)">
                <el-option v-for="(item, index) in arr1" :key="index" :label="item.name" :value="item.id"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column align="center" label="配合比" width="80">
            <template slot-scope="scope">
              <span class="table_link" style="cursor:pointer;" @click="childopen(scope.row,scope.$index)">查看</span>
            </template>
          </el-table-column>
          <el-table-column align="center" label="容重" prop="unitWeight"></el-table-column>
          <el-table-column align="center" label="生效日期" width="210">
            <template slot-scope="scope">
              <el-date-picker v-model="scope.row.effectiveDate" :disabled="radioType==1" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" style="width:100%">
              </el-date-picker>
            </template>
          </el-table-column>
          <el-table-column v-if="radioType==2" align="center" label="操作" width="120">
            <template slot-scope="scope">
              <el-button size="small" class="bottom_two" @click="delitem(scope.$index)">
                <i class="icon iconfont iconicon_button_delete" style="font-size: 12px"></i>
                删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="activedialog = ''">取 消</el-button>
        <el-button v-if="radioType==2" class="bottom_all" style="margin-left: 24px" @click="submit()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 配合比 -->
    <el-dialog v-dialogDrag :visible="dialogList.indexOf(activedialog2) == 1" width="680px" :close-on-click-modal="false" :before-close="closedialog2">
      <span slot="title" class="dialog-title">配合比</span>
      <div class="dialoginfo" style="padding-top: 0">
        <div v-if="radioType==2" style="padding-bottom:10px">
          <el-button size="mini" class="bottom_all" style="margin-left: 0" @click="addItem1()">
            <i class="icon iconfont iconicon_button_add" style="font-size: 12px"></i>
            添加
          </el-button>
        </div>
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="table1" tooltip-effect="dark">
          <el-table-column align="center" label="原物料" prop="markNumber">
            <template slot-scope="scope">
              <el-select v-model="scope.row.rawId" :disabled="radioType==1" placeholder="请选择" style="width:100%" @change="change2(scope.row,scope.$index)">
                <el-option v-for="(item, index) in arr2" :key="index" :label="item.itemName" :value="item.id"></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column align="center" label="配合比值">
            <template slot-scope="scope">
              <el-input v-model="scope.row.num" type="Number" placeholder="请输入" style="width:100%" clearable :disabled="radioType==1"></el-input>
            </template>
          </el-table-column>
          <el-table-column v-if="radioType==2" align="center" label="操作" width="120">
            <template slot-scope="scope">
              <el-button size="small" class="bottom_two" @click="delitem0(scope.$index)">
                <i class="icon iconfont iconicon_button_delete" style="font-size: 12px"></i>
                删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="activedialog2 = false">取 消</el-button>
        <el-button v-if="radioType==2" class="bottom_all" style="margin-left: 24px" @click="submit1()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 投标信息 -->
    <el-dialog :visible="dialogList.indexOf(activedialog) == 2" width="580px" :close-on-click-modal="false" :before-close="closedialog2">
      <span slot="title" class="dialog-title">投标信息</span>
      <div class="dialoginfo" style="padding-top: 0">
        <el-form ref="reffrom1" :rules="rules" label-position="top" :inline="true" :model="from1" label-width="110px">
          <el-form-item prop="winningBidders">
            <span slot="label">中标方</span>
            <el-input v-model="from1.winningBidders" style="width:500px" placeholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <span slot="label">成交价格</span>
            <el-input v-model="from1.dealPrice" style="width:500px" placeholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <span slot="label">投标价格</span>
            <el-input v-model="from1.dibPrice" style="width:500px" placeholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item prop="dibCost">
            <span slot="label">投标成本</span>
            <el-input v-model="from1.dibCost" style="width:500px" type="textarea" :rows="5" resize="none" placeholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item prop="loseBidCause">
            <span slot="label">未中标原因</span>
            <el-input v-model="from1.loseBidCause" style="width:500px" type="textarea" :rows="5" resize="none" placeholder="请输入" clearable></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="handleCancle">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px" @click="submitauditData()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 工程详情 -->
    <el-dialog v-dialogDrag :visible.sync="show" width="1200px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">工程信息</span>
      <div class="dialoginfo show">
        <el-form :inline="true" label-width="110px">
          <div class="form-title">工程基本信息</div>
          <el-form-item prop="name">
            <span slot="label" style="color:#FF0000;">工程名称</span>
            <el-input v-model="fromDate.name" placeholder="请输入" disabled></el-input>
          </el-form-item>
          <el-form-item prop="place">
            <span slot="label" style="color:#FF0000;">地理位置</span>
            <el-input v-model="fromDate.place" placeholder="请输入" disabled></el-input>
          </el-form-item>
          <el-form-item prop="expectedAmount" label-width="160px">
            <span slot="label" style="color:#FF0000;">预估用砼量（方）</span>
            <el-input v-model="fromDate.expectedAmount" style="width: 190px;" placeholder="请输入" disabled></el-input>
          </el-form-item>
          <el-form-item prop="typeId">
            <span slot="label">工程性质</span>
            <el-input v-model="fromDate.type" placeholder="请输入" disabled></el-input>
          </el-form-item>
          <el-form-item prop="rateOfProgressId">
            <span slot="label">项目进度</span>
            <el-input v-model="fromDate.rateOfProgress" placeholder="请输入" disabled></el-input>
          </el-form-item>
          <el-form-item prop="startTime">
            <span slot="label">起供时间</span>
            <el-date-picker v-model="fromDate.startTime" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" disabled></el-date-picker>
          </el-form-item>
          <el-form-item prop="tubularColumn">
            <span slot="label">管柱（米）</span>
            <el-input v-model="fromDate.tubularColumn" placeholder="请输入" disabled></el-input>
          </el-form-item>
          <el-form-item prop="fabricated">
            <span slot="label">装配式</span>
            <el-input v-model="fromDate.fabricated" placeholder="请输入" disabled></el-input>
          </el-form-item>
          <el-form-item prop="fabricated">
            <span slot="label">现场情况</span>
            <el-input v-model="fromDate.currentSituation" placeholder="请输入" disabled></el-input>
          </el-form-item>
          <div>
            <el-form-item prop="roadwork">
              <span slot="label" style="color:#FF0000;">施工单位</span>
              <el-input v-model="fromDate.roadwork" placeholder="请输入" disabled></el-input>
            </el-form-item>
            <el-form-item prop="roadworklInkman">
              <span slot="label" style="color:#FF0000;">联系人</span>
              <el-input v-model="fromDate.roadworklInkman" placeholder="请输入" disabled></el-input>
            </el-form-item>
            <el-form-item prop="roadworkPhone">
              <span slot="label" style="color:#FF0000;">电话</span>
              <el-input v-model="fromDate.roadworkPhone" placeholder="请输入" disabled></el-input>
            </el-form-item>
            <el-form-item prop="constructionUnit">
              <span slot="label">建设单位</span>
              <el-input v-model="fromDate.constructionUnit" placeholder="请输入" disabled></el-input>
            </el-form-item>
            <el-form-item prop="cuLinkman">
              <span slot="label">联系人</span>
              <el-input v-model="fromDate.cuLinkman" placeholder="请输入" disabled></el-input>
            </el-form-item>
            <el-form-item prop="cuPhone">
              <span slot="label">电话</span>
              <el-input v-model="fromDate.cuPhone" placeholder="请输入" disabled></el-input>
            </el-form-item>
            <el-form-item prop="contractSigningUnit">
              <span slot="label">合同单位</span>
              <el-input v-model="fromDate.contractSigningUnit" placeholder="请输入" disabled></el-input>
            </el-form-item>
            <el-form-item prop="clientTypeId">
              <span slot="label">客户类型</span>
              <el-input v-model="fromDate.clientType" placeholder="请输入" disabled></el-input>
            </el-form-item>
          </div>
          <div>
            <el-form-item prop="businessTypeId">
              <span slot="label" style="color:#FF0000;">业务类型</span>
              <el-input v-model="fromDate.businesName" placeholder="请输入" disabled></el-input>
            </el-form-item>
            <el-form-item prop="executePhase">
              <span slot="label" style="color:#FF0000;">执行阶段</span>
              <el-select v-model="fromDate.executePhase" placeholder="请选择" disabled>
                <el-option label="委托交底" :value="1"></el-option>
                <el-option label="评估" :value="2"></el-option>
                <el-option label="投标" :value="3"></el-option>
                <el-option label="合同交底" :value="4"></el-option>
              </el-select>
            </el-form-item>
          </div>
          <el-form-item prop="remark">
            <span slot="label">备注</span>
            <el-input v-model="fromDate.remark" style="width: 920px;" type="textarea" :rows="5" resize="none" placeholder="请输入" disabled></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="show=false">取 消</el-button>
      </span>
    </el-dialog>
    <!-- 高级搜索 -->
    <el-dialog v-dialogDrag :visible.sync="tableParamType" width="650px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">高级搜索</span>
      <div class="dialoginfo">
        <el-form :key="tableParam.principal" ref="reftableParam" :inline="true" :model="tableParam" label-width="110px">
          <el-form-item>
            <span slot="label">工程编号</span>
            <el-input v-model="tableParam.code" tplaceholder="请输入" clearable style="width:400px;"></el-input>
          </el-form-item>
          <!-- <el-form-item>
            <span slot="label">施工单位</span>
            <el-input v-model="tableParam.roadwork" tplaceholder="请输入" clearable style="width:400px;"></el-input>
          </el-form-item> -->
          <el-form-item>
            <span slot="label">联系人</span>
            <el-input v-model="tableParam.roadworklInkman" tplaceholder="请输入" clearable style="width:400px;"></el-input>
          </el-form-item>
          <el-form-item>
            <span slot="label">负责人</span>
            <el-input v-model="tableParam.principal" tplaceholder="请输入" clearable style="width:400px;"></el-input>
          </el-form-item>
          <el-form-item>
            <span slot="label">投标状态</span>
            <el-select v-model="tableParam.bidStatus" placeholder="请选择" style="width:400px;">
              <el-option label="投标中" value="1"></el-option>
              <el-option label="已中标" value="2"></el-option>
              <el-option label="未中标" value="3"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <span slot="label">登记时间</span>
            <el-date-picker v-model="startTimDateEndTimDate" style="width:400px;" type="datetimerange" unlink-panels value-format="yyyy-MM-dd HH:mm:ss" start-placeholder="开始时间" end-placeholder="结束时间" @change="tableParam.createTime=startTimDateEndTimDate[0]||'',tableParam.updateTime=startTimDateEndTimDate[1]||''"></el-date-picker>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="tableParamType=false,tableParam.code='',startTimDateEndTimDate=[],tableParam.createTime='',tableParam.updateTime='',tableParam.roadworklInkman='',tableParam.roadwork='',tableParam.principal='',tableParam.bidStatus=''">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px" @click="gettableData(),tableParamType=false">搜 索</el-button>
      </span>
    </el-dialog>
    <!-- 投标附件 -->
    <el-dialog v-dialogDrag :visible.sync="dibFileType" width="650px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">投标附件</span>
      <div class="dialoginfo">
        <div style="padding-left:50px;">
          <FileComponent fileCode="clarificaitonFile" :files="listFilesa2" @deleteFile="deleteFile2" @uplodeSuccess="uplodeSuccess2" />
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="dibFileType=false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px" @click="dibFileFun()">保 存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import FileComponent from './components/fileComponent';
import mixin from "@/mixins/ICPSmixin.js";
import { queryPage } from "@/api/internetSales/projectManagement.js";
import {
  UpdateDid,
  UpdateDidPrice,
  getList,
  saveOrUpdate,
  updateMix,
  saveDibFile,
} from "@/api/internetSales/tender.js";
import { QueryOneByid } from "@/api/internetSales/chanceManagement.js";
import { getListByTypeId } from "@/api/common.js";
import { getDicType } from "@/api/common.js";
export default {
  components: { FileComponent },
  mixins: [mixin],
  data() {
    return {
      dibFileType: false,
      radioType: 2,
      tableParamType: false,
      /*表格增删改查及下载接口*/
      queryPage: queryPage,
      /*表格数据*/
      tableData: [],
      /*表单页类型，0为无树状，1为有树状，有树状在el-main加上display:flex*/
      pagesType: 0,
      type: 0,
      dialogList: ["dialoga", "dialogb", "dialogc"],
      activedialog: "",
      activedialog2: "",
      low: "",
      from1: {
        winningBidders: "",
        dealPrice: "",
        dibPrice: "",
        dibCost: "",
        loseBidCause: ''
      },
      arr1: [],
      arr2: [],
      oldtable: [],
      table: [],
      table1: [],
      childindex: null,
      fromDate: {},
      show: false,
      startTimDateEndTimDate: [],
      listFilesa2: [],
      row: '',
      rules: {
        winningBidders: [{ required: true, message: "请输入中标方", trigger: "blur" },],
        loseBidCause: [{ required: true, message: "请输入未中标原因", trigger: "blur" },],
      },
      handleIndex: '',
      handleId: '',
    };
  },
  created() {
    this.tableParam = { ...this.tableParam, name: "", roadwork: "", isAssess: 3, code: '', createTime: '', updateTime: '', roadworklInkman: '', principal: '', bidStatus: '', };
    this.gettableData();
    getDicType({
      code: "MATname",
    }).then((res) => {
      this.arr2 = res.data.items;
    });
    getListByTypeId({
      typeId: 1,
    }).then((res) => {
      this.arr1 = res.data;
    });
  },
  methods: {
    handleCancle () {
      console.log(111111111111)
      this.activedialog = ''
      if (this.handleIndex || this.handleIndex===0) {
        UpdateDid({
          engineeringId: this.handleId,
          statusNum: this.copyDataSource[this.handleIndex].bidStatus,
        }).then((res) => {
          if (res.code === 1001) {
            this.gettableData();
          }
        });
      }
    },
    deleteFile2(index) {
      this.listFilesa2.splice(index, 1);
    },
    /**
     * @Description: 上传成功
     */
    uplodeSuccess2(data) {
      const params = {
        fileName: data.fileName,
        fileUrl: data.fileUrl,
        createTime: new Date().Format('yyyy-MM-dd hh:mm:ss'),
      }
      this.listFilesa2.push(params);
    },
    dibFileFun() {
      saveDibFile({ id: this.row.id, dibFile: JSON.stringify(this.listFilesa2) }).then((res) => {
        if (res.code == 1001) {
          this.$message({
            message: '操作成功',
            type: 'success'
          });
          this.dibFileType = false
          this.gettableData();
        }
      })
    },
    look5Fun(row) {
      this.row = row
      this.dibFileType = true
      this.listFilesa2 = []
      if (row.dibFile) {
        this.listFilesa2 = JSON.parse(row.dibFile)
      }
    },
    radioTypeFun() {
      this.editorMix(this.low, true)
      updateMix({ id: this.low.id, useMix: this.radioType }).then((res) => {
        if (res.code == 1001) {
          this.$message({
            message: '配合比绑定成功',
            type: 'success'
          });
          this.gettableData();
        }
      })
    },
    init() {
      /*重置数据*/
      this.tableParam.name = "";
      this.tableParam.roadwork = "";
      this.tableParam.code = "";
      this.tableParam.roadworklInkman = "";
      this.tableParam.principal = "";
      this.tableParam.bidStatus = "";
      this.startTimDateEndTimDate = [];
      this.tableParam.createTime = "";
      this.tableParam.updateTime = "";
      this.gettableData();
    },
    closedialog() {
      this.activedialog = "";
    },
    closedialog2() {
      this.activedialog2 = "";
    },
    /*投标状态修改*/
    change1(e, index) {
      this.handleIndex = index;
      this.handleId = e.id;
      this.$confirm(`你确定切换投标状态为${['', '投标中', '已中标', '未中标'][e.bidStatus * 1]}?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        cancelButtonClass: "bottom_all_two",
        confirmButtonClass: "bottom_all",
        type: "warning",
      }).then(() => {
        if (e.bidStatus == 3) {
          this.editorTender(e);
        }
        UpdateDid({
          engineeringId: e.id,
          statusNum: e.bidStatus,
        }).then((res) => {
          if (res.code === 1001) {
            this.$message.success('修改成功。');
          }
        });
      }).catch(() => {
        this.gettableData();
      });
    },
    /*价格与成本*/
    editorTender(low) {
      this.low = low;
      this.activedialog = "dialogc";
      this.from1.dealPrice = low.dealPrice;
      this.from1.winningBidders = low.winningBidders;
      this.from1.dibPrice = low.dibPrice;
      this.from1.dibCost = low.dibCost;
      this.from1.loseBidCause = low.loseBidCause;
      setTimeout(() => {
        this.$refs.reffrom1.clearValidate();
      }, 10);
    },
    /*价格与成本*/
    submitauditData() {
      this.$refs.reffrom1.validate((valid) => {
        if (valid) {
          UpdateDidPrice({ ...this.from1, id: this.low.id }).then((res) => {
            if (res.code == 1001) {
              this.$message({
                message: '操作成功',
                type: 'success'
              });
              this.gettableData();
              this.closedialog();
            }
          });
        } else {
          return false;
        }
      });
    },
    /*投标配合比*/
    editorMix(low, type) {
      this.low = low;
      this.activedialog = "dialoga";
      this.table = [];
      if (!type) {
        this.radioType = low.useMix
      }
      getList({ id: low.id, useMix: this.radioType, companyId: low.companyId }).then((res) => {
        this.table = this.copy(res.data) || [];
        this.oldtable = this.copy(res.data) || [];
      });
    },
    handleDetails(data) {
      QueryOneByid({ id: data.id }).then((res) => {
        this.fromDate = res.data;
        this.show = true;
      });
    },
    /*配合比*/
    childopen(low, index) {
      this.childindex = index;
      this.activedialog2 = "dialogb";
      this.table1 = this.copy(low.list);
    },
    addItem() {
      let data = {
        type: 1, //1新增，2修改，0删除
        engineeringId: this.low.id,
        markNumber: "",
        markNumberId: "",
        effectiveDate: "",
        list: [],
      };
      this.table.push(data);
    },
    addItem1() {
      let data = {
        type: 1, //1新增，2修改，0删除
        rawId: "",
        rawName: "",
        num: null,
      };
      this.table1.push(data);
    },
    change(low, index) {
      let type = false
      this.table.forEach((v, k) => {
        if (index != k && v.markNumberId == low.markNumberId) {
          type = true
        }
      })
      if (type) {
        this.$message({
          message: '标号不能重复！',
          type: 'warning'
        });
        low.markNumberId = ''
        return
      }
      low.markNumber = this.$fromatTable(
        this.arr1,
        low.markNumberId,
        "id",
        "name"
      );
    },
    change2(low, index) {
      let type = false
      this.table1.forEach((v, k) => {
        if (index != k && v.rawId == low.rawId) {
          type = true
        }
      })
      if (type) {
        this.$message({
          message: '原物料不能重复！',
          type: 'warning'
        });
        low.rawId = ''
        return
      }
      low.rawName = this.$fromatTable(this.arr2, low.rawId, "id", "itemName");
    },
    delitem(index) {
      this.table.splice(index, 1);
    },
    delitem0(index) {
      this.table1.splice(index, 1);
    },
    submit() {
      let type = false
      this.table.forEach((v) => {
        if (!v.markNumberId || !v.effectiveDate) {
          type = true
        }
      })
      if (type) {
        this.$message({
          message: '表格参数未填写完整！',
          type: 'warning'
        });
        return
      }
      let allHasData = this.table.filter((item) =>
        this.oldtable.some((items) => item.id == items.id)
      );
      let deleteData = this.oldtable.filter(
        (item) => !allHasData.some((items) => item.id == items.id)
      );
      let addData = this.table.filter(
        (item) => !allHasData.some((items) => item.id == items.id)
      );
      allHasData.forEach((res) => {
        res.type = 2;
      });
      deleteData.forEach((res) => {
        res.type = 0;
      });
      allHasData.forEach((res) => {
        let arr1 = res.list;
        let arr2 = this.oldtable.find((item) => item.id == res.id).list;
        let allHasData1 = arr1.filter((item) =>
          arr2.some((items) => item.id == items.id)
        );
        let deleteData1 = arr2.filter(
          (item) => !allHasData1.some((items) => item.id == items.id)
        );
        let addData1 = arr1.filter(
          (item) => !allHasData1.some((items) => item.id == items.id)
        );
        deleteData1.forEach((res) => {
          res.type = 0;
        });
        allHasData1.forEach((res) => {
          res.type = 2;
        });
        res.list = [...deleteData1, ...allHasData1, ...addData1];
      });
      let data = [...deleteData, ...allHasData, ...addData];
      saveOrUpdate(data).then((res) => {
        if (res.code === 1001) {
          this.$message({
            message: res.codeMsg,
            type: "success",
          });
          this.closedialog();
        }
      });
    },
    submit1() {
      let type = false
      this.table1.forEach((v) => {
        if (!v.rawId || !v.num) {
          type = true
        }
      })
      if (type) {
        this.$message({
          message: '表格参数未填写完整！',
          type: 'warning'
        });
        return
      }
      this.table[this.childindex].list = this.table1;
      let sum = 0;
      for (let i = 0; i < this.table1.length; i+=1) {
        sum+= this.table1[i].num*1
      }
      this.table[this.childindex].unitWeight = sum;
      this.activedialog2 = "";
    },
    sizeChange(value) {
      this.tableParam.pageSize = value;
      this.gettableData();
    },
  },
};
</script>

<style lang="scss" scoped>
.audit-title {
  @include discen_al;
  justify-content: space-between;
  padding: 0 0px 10px 0px;
}
.table_link {
  margin-left: 10px;
  color: $bg_color;
}

.table_link:hover {
  opacity: 0.8;
}
.el-input,
.el-select {
  width: 240px;
}
.score-container {
  border: 1px solid #e1e5ed;
  .score-list {
    border-bottom: 1px solid #e1e5ed;
    height: 48px;
  }
  .score-list:last-child {
    border: none;
  }
}
.score-title {
  margin-bottom: 10px;
}
</style>
